Research
Security News
Malicious npm Package Typosquats react-login-page to Deploy Keylogger
Socket researchers unpack a typosquatting package with malicious code that logs keystrokes and exfiltrates sensitive data to a remote server.
jsdoc-parse
Advanced tools
Package description
The jsdoc-parse npm package is a tool for parsing JSDoc comments in JavaScript files and generating JSON output. It is useful for extracting documentation information from code comments and can be integrated into documentation generation workflows.
Parsing JSDoc comments
This feature allows you to parse JSDoc comments from JavaScript code and generate a JSON representation of the documentation. The code sample demonstrates how to parse a simple JSDoc comment and output the parsed JSON.
const jsdocParse = require('jsdoc-parse');
const fs = require('fs');
const jsdocComments = `
/**
* Adds two numbers together.
* @param {number} a - The first number.
* @param {number} b - The second number.
* @returns {number} The sum of the two numbers.
*/
function add(a, b) {
return a + b;
}
`;
jsdocParse({ src: jsdocComments }).then(output => {
console.log(JSON.stringify(output, null, 2));
});
Generating JSON output
This feature allows you to generate JSON output from JSDoc comments and save it to a file. The code sample demonstrates how to parse JSDoc comments and write the resulting JSON to a file named 'output.json'.
const jsdocParse = require('jsdoc-parse');
const fs = require('fs');
const jsdocComments = `
/**
* Multiplies two numbers together.
* @param {number} a - The first number.
* @param {number} b - The second number.
* @returns {number} The product of the two numbers.
*/
function multiply(a, b) {
return a * b;
}
`;
jsdocParse({ src: jsdocComments }).then(output => {
fs.writeFileSync('output.json', JSON.stringify(output, null, 2));
});
The 'documentation' package is a documentation generation tool that supports JSDoc comments. It can generate HTML, Markdown, and JSON documentation from JavaScript code. Compared to jsdoc-parse, 'documentation' offers more output format options and additional features like linting and serving documentation as a web server.
The 'jsdoc' package is a popular tool for generating HTML documentation from JSDoc comments. It provides a wide range of configuration options and supports plugins for extending its functionality. While jsdoc-parse focuses on parsing and generating JSON output, 'jsdoc' is more comprehensive in terms of generating complete documentation websites.
The 'esdoc' package is a documentation generator for JavaScript that supports ES6+ syntax. It provides features like coverage reports, test integration, and a plugin system. Compared to jsdoc-parse, 'esdoc' offers more advanced features and is tailored for modern JavaScript syntax.
Readme
Transforms jsdoc data into something more suitable for use as template input. Also adds a few tags to the default set:
@category <string>
: Useful for grouping identifiers by category.@done
: Used to mark @todo
items as complete.@typicalname
: If set on a class, namespace or module, child members will documented using this typical name as the parent name. Real-world typical name examples are $
(the typical name for jQuery
instances), _
(underscore) etc.@chainable
: Set to mark a method as chainable (has a return value of this
).This module is built into jsdoc-to-markdown, you can see the output using this command:
$ jsdoc2md --json <files>
© 2014-24 Lloyd Brookes <75pound@gmail.com>.
Tested by test-runner. Documented by jsdoc-to-markdown.
FAQs
Unknown package
The npm package jsdoc-parse receives a total of 86,229 weekly downloads. As such, jsdoc-parse popularity was classified as popular.
We found that jsdoc-parse demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket researchers unpack a typosquatting package with malicious code that logs keystrokes and exfiltrates sensitive data to a remote server.
Security News
The JavaScript community has launched the e18e initiative to improve ecosystem performance by cleaning up dependency trees, speeding up critical parts of the ecosystem, and documenting lighter alternatives to established tools.
Product
Socket now supports four distinct alert actions instead of the previous two, and alert triaging allows users to override the actions taken for all individual alerts.